

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/IKKIS_LOGO.png">
  <link rel="icon" href="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/IKKIS_LOGO.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="Ikki">
  <meta name="keywords" content="">
  
    <meta name="description" content="1. 用户和用户组    使用操作系统的人都是用户   用户组是具有相同系统权限的一组用户  2. 配置文件 2.1 &#x2F;etc&#x2F;group   &#x2F;etc&#x2F;group 存储当前系统中所有用户组信息   root 组编号为 0   1-499系统预留的编号 预留给安装的软件和服务的   用户手动创建的用户组从500开始   组密码占位符都是x   如果组内只有一个用户，而且用户名和组名相同的话，是可以">
<meta property="og:type" content="article">
<meta property="og:title" content="03.用户和用户组">
<meta property="og:url" content="http://81.68.132.127/2022/10/23/dev_ops/linux/%E7%94%A8%E6%88%B7%E5%92%8C%E7%94%A8%E6%88%B7%E7%BB%84/index.html">
<meta property="og:site_name" content="IKKI">
<meta property="og:description" content="1. 用户和用户组    使用操作系统的人都是用户   用户组是具有相同系统权限的一组用户  2. 配置文件 2.1 &#x2F;etc&#x2F;group   &#x2F;etc&#x2F;group 存储当前系统中所有用户组信息   root 组编号为 0   1-499系统预留的编号 预留给安装的软件和服务的   用户手动创建的用户组从500开始   组密码占位符都是x   如果组内只有一个用户，而且用户名和组名相同的话，是可以">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/beijing/iTab-8oy372.jpeg">
<meta property="article:published_time" content="2022-10-23T15:15:06.000Z">
<meta property="article:modified_time" content="2022-10-24T09:52:23.147Z">
<meta property="article:author" content="Ikki">
<meta property="article:tag" content="运维">
<meta property="article:tag" content="linux">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/beijing/iTab-8oy372.jpeg">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>03.用户和用户组 - IKKI</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  



  
<link rel="stylesheet" href="/fluid/css/fluid-extention.css">
<link rel="stylesheet" href="/fluid/css/nihao.css">



  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"81.68.132.127","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"left","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":3},"lazyload":{"enable":true,"loading_img":"https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 100vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Ikki-BUG制造者</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('http://image.ikki0603.cn') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="03.用户和用户组"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-10-23 23:15" pubdate>
          2022年10月23日 晚上
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          1.5k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          13 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
        <div class="scroll-down-bar">
          <i class="iconfont icon-arrowdown"></i>
        </div>
      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="padding-left: 2rem; margin-right: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">03.用户和用户组</h1>
            
              <p class="note note-info">
                
                  
                    本文最后更新于：2022年10月24日 下午
                  
                
              </p>
            
            
              <div class="markdown-body">
                
                <h2 id="1-用户和用户组"><a href="#1-用户和用户组" class="headerlink" title="1. 用户和用户组 "></a>1. 用户和用户组 </h2><ul>
<li>  使用操作系统的人都是用户</li>
<li>  用户组是具有相同系统权限的一组用户</li>
</ul>
<h2 id="2-配置文件"><a href="#2-配置文件" class="headerlink" title="2. 配置文件 "></a>2. 配置文件 </h2><h3 id="2-1-etc-group"><a href="#2-1-etc-group" class="headerlink" title="2.1 /etc/group"></a>2.1 /etc/group</h3><ul>
<li>  /etc/group 存储当前系统中所有用户组信息</li>
<li>  <code>root</code> 组编号为 <code>0</code></li>
<li>  <code>1-499</code>系统预留的编号 预留给安装的软件和服务的</li>
<li>  用户手动创建的用户组从<code>500</code>开始</li>
<li>  组密码占位符都是<code>x</code></li>
<li>  如果组内只有一个用户，而且用户名和组名相同的话，是可以省略用户名的</li>
</ul>
<p><code>root:x:0:root</code></p>
<table>
<thead>
<tr>
<th>组的名称</th>
<th>组的名称</th>
<th>组编号</th>
<th>组中用户名列表</th>
</tr>
</thead>
<tbody><tr>
<td>root</td>
<td>x</td>
<td>0</td>
<td>root</td>
</tr>
<tr>
<td>bin</td>
<td>x</td>
<td>1</td>
<td></td>
</tr>
</tbody></table>
<h3 id="2-2-etc-gshadow"><a href="#2-2-etc-gshadow" class="headerlink" title="2.2 /etc/gshadow"></a>2.2 /etc/gshadow</h3><ul>
<li>  存放当前系统中用户组的密码信息</li>
<li>  和<code>/etc/group</code>中的记录一一对应</li>
</ul>
<p><code>root:*::root</code></p>
<table>
<thead>
<tr>
<th>组的名称</th>
<th>组密码,为空</th>
<th>组管理者,为空表示都可以管理这个组</th>
<th>组中用户名列表</th>
</tr>
</thead>
<tbody><tr>
<td>root</td>
<td>*</td>
<td></td>
<td>root</td>
</tr>
</tbody></table>
<h3 id="2-3-etc-passwd"><a href="#2-3-etc-passwd" class="headerlink" title="2.3 /etc/passwd"></a>2.3 /etc/passwd</h3><ul>
<li>  存储当前系统中所有用户的信息</li>
</ul>
<p><code>root:x:0:0:root:/root:/bin/bash</code></p>
<table>
<thead>
<tr>
<th>用户名</th>
<th>密码占位符</th>
<th>用户编号</th>
<th>用户组编号</th>
<th>用户注释信息</th>
<th>用户主目录</th>
<th>shell类型</th>
</tr>
</thead>
<tbody><tr>
<td>root</td>
<td>x</td>
<td>0</td>
<td>0</td>
<td>root</td>
<td>/root</td>
<td>/bin/bash</td>
</tr>
</tbody></table>
<h3 id="2-4-etc-shadow"><a href="#2-4-etc-shadow" class="headerlink" title="2.4 /etc/shadow"></a>2.4 /etc/shadow</h3><ul>
<li>  存放当前系统中所有用户的密码信息</li>
<li>  user:xxx:::::::</li>
<li>  用户名:密码:</li>
</ul>
<p><code>root:password:17982:0:99999:7:::</code></p>
<table>
<thead>
<tr>
<th>内容</th>
<th>含义</th>
</tr>
</thead>
<tbody><tr>
<td>root</td>
<td>用户名</td>
</tr>
<tr>
<td>password</td>
<td>单向加密后的密码</td>
</tr>
<tr>
<td>17982</td>
<td>修改日期,这个是表明上一次修改密码的日期与1970-1-1相距的天数密码不可改的天数：假如这个数字是8，则8天内不可改密码，如果是0，则随时可以改</td>
</tr>
<tr>
<td>0</td>
<td>这个是表明上一次修改密码的日期与1970-1-1相距的天数密码不可改的天数：假如这个数字是8，则8天内不可改密码，如果是0，则随时可以改</td>
</tr>
<tr>
<td>99999</td>
<td>如果是99999则永远不用改。如果是其其他数字比如12345，那么必须在距离1970-1-1的12345天内修改密码，否则密码失效</td>
</tr>
<tr>
<td>7</td>
<td>修改期限前N天发出警告</td>
</tr>
<tr>
<td></td>
<td>密码过期的宽限天数</td>
</tr>
<tr>
<td></td>
<td>帐号失效日期</td>
</tr>
<tr>
<td></td>
<td>保留：被保留项，暂时还没有被用上</td>
</tr>
</tbody></table>
<h2 id="3-用户命令"><a href="#3-用户命令" class="headerlink" title="3. 用户命令 "></a>3. 用户命令 </h2><p>显示登录的用户名</p>
<figure class="highlight bash"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-ctf481lacl5vph"></i><span>bash</span><div class="collapse show" id="collapse-ctf481lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">whoami</span><br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-20-29_366cbf60.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-20-29"></p>
<p>显示指定用户信息，包括用户编号，用户名所在用户组的编号及名称，附属组列表</p>
<figure class="highlight applescript"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-s4txs7lacl5vph"></i><span>applescript</span><div class="collapse show" id="collapse-s4txs7lacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs applescript"><span class="hljs-built_in">id</span> root  <br><br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-20-52_1df8bb47.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-20-52"></p>
<p>显示root用户所在的所有组</p>
<figure class="highlight bash"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-3otygzlacl5vph"></i><span>bash</span><div class="collapse show" id="collapse-3otygzlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-built_in">groups</span> root <br><br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-22-05_61368a6f.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-22-05"></p>
<h2 id="4-用户和用户组操作"><a href="#4-用户和用户组操作" class="headerlink" title="4. 用户和用户组操作 "></a>4. 用户和用户组操作 </h2><h3 id="4-1-添加用户组"><a href="#4-1-添加用户组" class="headerlink" title="4.1 添加用户组"></a>4.1 添加用户组</h3><figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-el8avwlacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-el8avwlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk">groupadd stu<br>cat  <span class="hljs-regexp">/etc/g</span>roup<br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-23-32_7dba5ede.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-23-32"></p>
<h3 id="4-2-修改用户组名称"><a href="#4-2-修改用户组名称" class="headerlink" title="4.2 修改用户组名称"></a>4.2 修改用户组名称</h3><figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-rrgvwalacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-rrgvwalacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk">groupmod -n student stu<br>cat  <span class="hljs-regexp">/etc/g</span>roup<br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-25-30_3df972ad.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-25-30"></p>
<h3 id="4-3-修改用户组编号"><a href="#4-3-修改用户组编号" class="headerlink" title="4.3 修改用户组编号"></a>4.3 修改用户组编号</h3><figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-o5e80ylacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-o5e80ylacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk">groupmod -g <span class="hljs-number">666</span> student<br>cat  <span class="hljs-regexp">/etc/g</span>roup<br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-26-10_ab0e4929.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-26-10"></p>
<h3 id="4-4-创建分组并指定编号"><a href="#4-4-创建分组并指定编号" class="headerlink" title="4.4 创建分组并指定编号"></a>4.4 创建分组并指定编号</h3><figure class="highlight apache"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-nf0ceolacl5vph"></i><span>apache</span><div class="collapse show" id="collapse-nf0ceolacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs apache"><span class="hljs-attribute">groupadd</span> -g <span class="hljs-number">888</span> teacher<br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-26-48_5654e277.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-26-48"></p>
<h3 id="4-5-删除用户组"><a href="#4-5-删除用户组" class="headerlink" title="4.5 删除用户组"></a>4.5 删除用户组</h3><figure class="highlight ebnf"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-vrgzmplacl5vph"></i><span>ebnf</span><div class="collapse show" id="collapse-vrgzmplacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs ebnf"><span class="hljs-attribute">groupdel student</span><br></code></pre></td></tr></table></div></figure>

<h3 id="4-6-添加用户"><a href="#4-6-添加用户" class="headerlink" title="4.6 添加用户"></a>4.6 添加用户</h3><ul>
<li>  如果创建用户的时候没有指定用户组，系统会为他创建一个和用户名相同的用户组</li>
</ul>
<figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-106hjalacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-106hjalacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs awk">groupadd stu  <span class="hljs-regexp">//</span>添加用户组<br>useradd -g stu zhangsan  <span class="hljs-regexp">//</span>创建用户并指定用户组<br>useradd -g stu lisi      <span class="hljs-regexp">//</span>创建用户并指定用户组<br><br>id zhangsan<br>id lisi<br><br>useradd -d <span class="hljs-regexp">/home/</span>wangwu wangwu   <span class="hljs-regexp">//</span>创建用户并指定家目录<br><br>passwd zhangsan <span class="hljs-regexp">//</span>root用户可以设置用户的密码<br><br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-35-25_3af25c84.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-35-25"></p>
<h3 id="4-7-指定个人文件夹"><a href="#4-7-指定个人文件夹" class="headerlink" title="4.7 指定个人文件夹"></a>4.7 指定个人文件夹</h3><figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-ewmz4nlacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-ewmz4nlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs awk">usermod -d <span class="hljs-regexp">/home/</span>wangwu2 wangwu<br><br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-35-07_2a66ec82.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-35-07"></p>
<h3 id="4-8-修改用户组"><a href="#4-8-修改用户组" class="headerlink" title="4.8 修改用户组"></a>4.8 修改用户组</h3><figure class="highlight ebnf"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-9l8f2jlacl5vph"></i><span>ebnf</span><div class="collapse show" id="collapse-9l8f2jlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs ebnf"><span class="hljs-attribute">usermod -g stu wangwu</span><br><br></code></pre></td></tr></table></div></figure>
<p><img src="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/dev_ops/linux/2022-10-23-05-37-06_737c197b.png" srcset="https://ikkiss.oss-cn-hangzhou.aliyuncs.com/images/myblog/loading.gif" lazyload alt="2022-10-23-05-37-06"></p>
<h3 id="4-9-删除用户"><a href="#4-9-删除用户" class="headerlink" title="4.9 删除用户"></a>4.9 删除用户</h3><figure class="highlight awk"><i class="iconfont icon-top" type="button" data-toggle="collapse" data-target="#collapse-gxidemlacl5vph"></i><span>awk</span><div class="collapse show" id="collapse-gxidemlacl5vph"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs awk">userdel wangwu<br>userdel -r wangwu <span class="hljs-regexp">//</span>删除用户的时候级联删除对应的目录<br><br></code></pre></td></tr></table></div></figure>
                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/%E8%BF%90%E7%BB%B4/" class="category-chain-item">运维</a>
  
  
    <span>></span>
    
  <a href="/categories/%E8%BF%90%E7%BB%B4/linux/" class="category-chain-item">linux</a>
  
  

  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/%E8%BF%90%E7%BB%B4/">#运维</a>
      
        <a href="/tags/linux/">#linux</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>03.用户和用户组</div>
      <div>http://81.68.132.127/2022/10/23/dev_ops/linux/用户和用户组/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>Ikki</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年10月23日</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>更新于</div>
          <div>2022年10月24日</div>
        </div>
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/10/23/dev_ops/linux/%E6%9D%83%E9%99%90/" title="04.权限">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">04.权限</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2022/10/23/dev_ops/linux/vi%E5%91%BD%E4%BB%A4/" title="02.vi命令">
                        <span class="hidden-mobile">02.vi命令</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
  <article id="comments" lazyload>
    
  <div id="valine"></div>
  <script type="text/javascript">
    Fluid.utils.loadComments('#valine', function() {
      Fluid.utils.createScript('https://lib.baomitu.com/valine/1.5.1/Valine.min.js', function() {
        var options = Object.assign(
          {"appId":"6KzYWc2oaEBaHgNl4UIicMJC-gzGzoHsz","appKey":"vJ4FIwKeHRmHraCJraAsjyZ7","path":"window.location.pathname","placeholder":"请输入你的评论\n昵称为必填项目(输入QQ号码可以自动获取昵称和邮箱)\n虽然email不是必选，但是填写了email可以收到推送通知哦！","avatar":"retro","meta":["nick","mail","link"],"requiredFields":[],"pageSize":10,"lang":"zh-CN","highlight":true,"recordIP":true,"serverURLs":"","emojiCDN":null,"emojiMaps":null,"enableQQ":true},
          {
            el: "#valine",
            path: window.location.pathname
          }
        )
        new Valine(options);
        Fluid.utils.waitElementVisible('#valine .vcontent', () => {
          var imgSelector = '#valine .vcontent img:not(.vemoji)';
          Fluid.plugins.imageCaption(imgSelector);
          Fluid.plugins.fancyBox(imgSelector);
        })
      });
    });
  </script>
  <noscript>Please enable JavaScript to view the comments</noscript>


  </article>


          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
      IKKI-专业BUG开发
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="/fluid/js/star.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
